package com.example.demo.day.config.learn.design.factory.x1;

public class SuvCarFactory {

    public static final String RED = "red";
    public static final String GREEN = "green";
    public static final String BLUE = "blue";

    //根据颜色来生产出对应的SUV
    public SuvCar create(String color) {
        if (RED.equals(color)) {
            return new SuvCar(color);
        } else if (GREEN.equals(color)) {
            return new SuvCar(color);
        } else if (BLUE.equals(color)) {
            return new SuvCar(color);
        } else {
            throw new RuntimeException("No such color: " + color);
        }
    }
}
